//
//  CurrencyExchangeJa.m
//  MarketDataColloctor
//
//  Created by jiro on 10/03/11.
//  Copyright 2010 jiro music. All rights reserved.
//

#import "CurrencyExchangeJa.h"

#import "DbConstants.h"
#import "DbUtility.h"


NSString* CurrencyExchangeJa::tableName()
{
	return kText_CurrencyExchangeJaTable;
}

NSString* CurrencyExchangeJa::queryCreateTable()
{
	NSString* s = [ NSString stringWithFormat:
		@"create table %@ ( %@ %@, %@ %@, %@ %@, %@ %@, %@ %@, %@ %@, %@ %@, %@( %@, %@, %@ ) );",
			kText_CurrencyExchangeJaTable, 
			kText_Code, kText_Text,
			kText_TargetCurrencyCode, kText_Text,
			kText_ExchangeDate, kText_TimestampWithTimeZone,
			kText_OpenPrice, kText_Real,
			kText_HighPrice, kText_Real,
			kText_LowPrice, kText_Real, 
			kText_ClosePrice, kText_Real,
			kText_PrimaryKey, kText_Code, kText_TargetCurrencyCode, kText_ExchangeDate
	];
	return s;
}

NSString* CurrencyExchangeJa::querySelectAll( const std::vector< ClauseNode >& clauses )
{
	NSString* s = DbTableEntry::querySelectAll( CurrencyExchangeJa::tableName(), clauses );
	return s;
}

NSString* CurrencyExchangeJa::querySelect( const std::vector< FieldNode >& fieldNodes, const std::vector< ClauseNode >& clauses )
{
	NSString* s = DbTableEntry::querySelect( fieldNodes, CurrencyExchangeJa::tableName(), clauses );
	return s;
}

CurrencyExchangeJa::CurrencyExchangeJa()
{
}

CurrencyExchangeJa::CurrencyExchangeJa( std::vector< const char* > values )
	: DbExchangeTableEntry::DbExchangeTableEntry( values )
{
}


NSString* CurrencyExchangeJa::sqlInsertStatement() const
{
	NSString* s = [ NSString stringWithFormat:
		@"insert into %@ values %@;",
		CurrencyExchangeJa::tableName(), queryInsertValue() ];
	return s;
}

NSString* CurrencyExchangeJa::queryInsertValue() const
{
	NSString*s = [ NSString stringWithFormat: @"( '%@', '%@', '%@', %f, %f, %f, %f )",
		code, targetCurrencyCode, [ exchangeDate description ], openPrice, highPrice, lowPrice, closePrice ];
	return s;
}
